package com.ruoyi.web.controller.gas;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gas.domain.GasDriverInfo;
import com.ruoyi.gas.service.IGasDriverInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Controller
 * 
 * @author morris
 * @date 2023-12-08
 */
@Api("驾驶员信息")
@RestController
@RequestMapping("/gas/driverInfo")
public class GasDriverInfoController extends BaseController
{
    @Autowired
    private IGasDriverInfoService gasDriverInfoService;

    /**
     * 查询列表
     */
    @ApiOperation("列表")
    @PreAuthorize("@ss.hasPermi('gas:driverInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(GasDriverInfo gasDriverInfo)
    {
        startPage();
        List<GasDriverInfo> list = gasDriverInfoService.selectGasDriverInfoList(gasDriverInfo);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('gas:driverInfo:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GasDriverInfo gasDriverInfo)
    {
        List<GasDriverInfo> list = gasDriverInfoService.selectGasDriverInfoList(gasDriverInfo);
        ExcelUtil<GasDriverInfo> util = new ExcelUtil<GasDriverInfo>(GasDriverInfo.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 获取详细信息
     */
    @ApiOperation("查询详细信息")
    @PreAuthorize("@ss.hasPermi('gas:driverInfo:query')")
    @GetMapping(value = "/{driverId}")
    public AjaxResult getInfo(@PathVariable("driverId") Long driverId)
    {
        return success(gasDriverInfoService.selectGasDriverInfoByDriverId(driverId));
    }

    /**
     * 新增
     */
    @ApiOperation("新增")
    @PreAuthorize("@ss.hasPermi('gas:driverInfo:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GasDriverInfo gasDriverInfo)
    {
        return toAjax(gasDriverInfoService.insertGasDriverInfo(gasDriverInfo));
    }

    /**
     * 修改
     */
    @ApiOperation("修改")
    @PreAuthorize("@ss.hasPermi('gas:driverInfo:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GasDriverInfo gasDriverInfo)
    {
        return toAjax(gasDriverInfoService.updateGasDriverInfo(gasDriverInfo));
    }

    /**
     * 删除
     */
    @ApiOperation("删除")
    @PreAuthorize("@ss.hasPermi('gas:driverInfo:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{driverIds}")
    public AjaxResult remove(@PathVariable Long[] driverIds)
    {
        return toAjax(gasDriverInfoService.deleteGasDriverInfoByDriverIds(driverIds));
    }
}
